package com.bupt.cosmfl.cosmflweb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bupt.cosmfl.cosmflweb.constant.Path;
import com.bupt.cosmfl.cosmflweb.constant.ResponseResult;
import com.bupt.cosmfl.cosmflweb.dto.PageDTO;
import com.bupt.cosmfl.cosmflweb.model.NodeGroupEntityVO;
import com.bupt.cosmfl.cosmflweb.service.NodeGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author fangtiewei
 * @Date 2021/7/28 12:00
 * @Description
 */
@RestController
@RequestMapping("/nodeGroup")
public class NodeGroupController {

    @Autowired
    private NodeGroupService nodeGroupService;

    @GetMapping(Path.GROUP_LIST)
    public ResponseResult<Object> list(@Valid PageDTO dto){
        Map<String,Object> res = new HashMap<>();
        IPage<NodeGroupEntityVO> nodeGroupPage = nodeGroupService.list(dto);
        res.put("nodeGroupList",nodeGroupPage.getRecords());
        res.put("total",nodeGroupPage.getTotal());
        return ResponseResult.ok(res);
    }

}
